package com.own.business.wallet.business.entity;

import com.own.business.wallet.common.exception.WalletException;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * WalletPayOrderForm
 *
 * @author chenxueli
 * @date 2023-07-27 21:23:00
 */
@Data
public class WalletRefundOrderForm implements Serializable {

    @Schema(title = "商户订单号")
    private String outTradeNo;

    @Schema(title = "商户退款订单号")
    private String outRefundNo;

    @Schema(title = "退款原因")
    private String reason;

    @Schema(title = "原支付金额（分）")
    private Integer oldTotalAmount;

    @Schema(title = "退款总金额（分）")
    private Integer totalAmount;

    public void check() {
        if (totalAmount == null || totalAmount <= 0) {
            throw new WalletException("退款金额不能小于等于0");
        }
        if (StringUtils.isBlank(outTradeNo)) {
            throw new WalletException("商户订单号不能为空");
        }
        if (StringUtils.isBlank(outRefundNo)) {
            throw new WalletException("商户退款订单号不能为空");
        }
    }

}
